<template>
  <view class="index">
    <view class="jtop">
      <view class="status_bar"><!-- 这里是状态栏 --></view>
      <view class="jtop_l" @tap="navigateBack"
        ><image src="../../static/img/ic_back.png"></image
      ></view>
      <!-- <view class="jtop_l" @tap="navigateBack">关闭</view> -->
      <view class="jtop_c">天府广场项目进度计划横道图</view>
      <view class="jtop_r" @tap="jshow_pop"
        ><image src="../../static/img/index/ic_ellipsis.png"></image
      ></view>
    </view>
    <view class="tophr"></view>

    <!-- 无内容 -->
    <view class="no" v-if="nodata">
      <view class="no_t">
        <image src="../../static/img/index/2/ic_total plan_grey.png"></image>
      </view>
      <view class="no_c">
        暂无进度计划
      </view>
      <view class="no_f" @tap="btTC2">
        新建进度计划
      </view>
    </view>

    <view class="wl_nr" v-if="!nodata">
      <view class="wl_top">
        <view class="wl_t wl_t1">序号</view>
        <view class="wl_t wl_t2">工程项目</view>
        <view class="wl_t wl_t3">开工时间<br />含流水段</view>
        <view class="wl_t wl_t4">完工时间<br />含流水段</view>
        <view class="wl_t wl_t5">历时<br />(天)</view>

        <view
          class="wl_t wl_t6"
          v-for="(aitem, aindex) in aitems"
          :key="aitem.id"
          >{{ aitem }}</view
        >

        <!-- <view class="wl_t wl_t6">2020年1月</view> v-for="(item, index) in Array.prototype.reverse.call(items)"-->
      </view>

      <view class="wl_cbox">
        <view
          class="wl_c"
          @longpress="logoTime(item.id)"
          v-for="(item, index) in items"
          :key="item.id"
        >
          <view class="wl_cb wl_cb1">{{ items.length - index }}</view>
          <view class="wl_cb wl_cb2">{{
            item.name.length < 11
              ? item.name
              : item.name.substring(0, 10) + '...'
          }}</view>
          <view class="wl_cb wl_cb3">{{ item.beginDate }}</view>
          <view class="wl_cb wl_cb4">{{ item.endDate }}</view>
          <view class="wl_cb wl_cb5">{{ item.duration }}</view>

          <view
            class="wl_cb wl_cb6"
            v-for="(bitem, bindex) in item.percentList"
            :key="bitem.month"
          >
            <!-- 	{{bitem.percentage}} -->
            <em
              :style="{
                width: bitem.percentage + '%',
                float: bitem.first ? 'right' : 'left',
              }"
            ></em>
            <i></i><i class="i2"></i>
          </view>

          <!-- <view class="wl_cb wl_cb6">
							<em style="width: 100%;"></em>
							<i></i><i class="i2"></i>
						</view> -->
        </view>

        <!-- 			<view class="wl_c" @longpress="logoTime()">
					<view class="wl_cb wl_cb1">1</view>
					<view class="wl_cb wl_cb2">主楼主体结构</view>
					<view class="wl_cb wl_cb3">2020/3/1</view>
					<view class="wl_cb wl_cb4">2020/6/30</view>
					<view class="wl_cb wl_cb5">90</view>
					<view class="wl_cb wl_cb6">
						<em style="width: 20%; float: right;"></em>
						<i></i><i class="i2"></i>
					</view>
					<view class="wl_cb wl_cb6">
						<em style="width: 100%;"></em>
						<i></i><i class="i2"></i>
					</view>
					<view class="wl_cb wl_cb6">
						<em style="width: 100%;"></em>
						<i></i><i class="i2"></i>
					</view>
					<view class="wl_cb wl_cb6">
						<em style="width: 33%;"></em>
						<i></i><i class="i2"></i>
					</view>
					<view class="wl_cb wl_cb6">
						<em style="width:0%;"></em>
						<i></i><i class="i2"></i>
					</view>
					<view class="wl_cb wl_cb6">
						<em style="width:0%;"></em>
						<i></i><i class="i2"></i>
					</view>
					<view class="wl_cb wl_cb6">
						<em style="width:0%;"></em>
						<i></i><i class="i2"></i>
					</view>
					<view class="wl_cb wl_cb6">
						<em style="width:0%;"></em>
						<i></i><i class="i2"></i>
					</view>
					<view class="wl_cb wl_cb6">
						<em style="width:0%;"></em>
						<i></i><i class="i2"></i>
					</view>
					<view class="wl_cb wl_cb6">
						<em style="width:0%;"></em>
						<i></i><i class="i2"></i>
					</view>
					<view class="wl_cb wl_cb6">
						<em style="width:0%;"></em>
						<i></i><i class="i2"></i>
					</view>
					<view class="wl_cb wl_cb6">
						<em style="width:0%;"></em>
						<i></i><i class="i2"></i>
					</view>
				</view>
				
				
				
				
		<view class="wl_c" @longpress="logoTime">
			<view class="wl_cb wl_cb1">1</view>
			<view class="wl_cb wl_cb2">主楼主体结构</view>
			<view class="wl_cb wl_cb3">2020/3/1</view>
			<view class="wl_cb wl_cb4">2020/6/30</view>
			<view class="wl_cb wl_cb5">90</view>
			<view class="wl_cb wl_cb6">
				<em style="width: 0%;"></em>
				<i></i><i class="i2"></i>
			</view>
			<view class="wl_cb wl_cb6">
				<em style="width: 60%; float: right;"></em>
				<i></i><i class="i2"></i>
			</view>
			<view class="wl_cb wl_cb6">
				<em style="width: 100%;"></em>
				<i></i><i class="i2"></i>
			</view>
			<view class="wl_cb wl_cb6">
				<em style="width: 70%;"></em>
				<i></i><i class="i2"></i>
			</view>
			<view class="wl_cb wl_cb6">
				<em style="width:0%;"></em>
				<i></i><i class="i2"></i>
			</view>
			<view class="wl_cb wl_cb6">
				<em style="width:0%;"></em>
				<i></i><i class="i2"></i>
			</view>
			<view class="wl_cb wl_cb6">
				<em style="width:0%;"></em>
				<i></i><i class="i2"></i>
			</view>
			<view class="wl_cb wl_cb6">
				<em style="width:0%;"></em>
				<i></i><i class="i2"></i>
			</view>
			<view class="wl_cb wl_cb6">
				<em style="width:0%;"></em>
				<i></i><i class="i2"></i>
			</view>
			<view class="wl_cb wl_cb6">
				<em style="width:0%;"></em>
				<i></i><i class="i2"></i>
			</view>
			<view class="wl_cb wl_cb6">
				<em style="width:0%;"></em>
				<i></i><i class="i2"></i>
			</view>
			<view class="wl_cb wl_cb6">
				<em style="width:0%;"></em>
				<i></i><i class="i2"></i>
			</view>
		</view>
		
				 -->
      </view>
    </view>
    <image
      src="../../static/img/index/5/xx2.png"
      class="xx2"
      @click="btTC2"
    ></image>
    <view class="jfooter">
      <view class="jfooter_b" @tap="jf01">
        <image
          src="../../static/img/index/new/shopping.png"
          class="jfooter_i"
        ></image>
        <view class="jfooter_t">采购计划</view>
      </view>
      <view class="jfooter_b active">
        <image
          src="../../static/img/index/new/Partition_fill2.png"
          class="jfooter_i"
        ></image>
        <view class="jfooter_t">进度计划</view>
      </view>
      <!-- <view class="jfooter_b" @tap="jf02">
				<image src="../../static/img/index/new/calendar.png" class="jfooter_i"></image>
				<view class="jfooter_t">日常计划</view>
			</view> -->

      <!-- <view class="jfooter_b" @tap="jf04">
				<image src="../../static/img/index/new/solution.png" class="jfooter_i"></image>
				<view class="jfooter_t">领用计划</view>
			</view> -->
    </view>

    <!-- 弹出层 -->
    <view :class="[ashowpop ? 'tc' : 'tc hide']">
      <view class="jtop_bj" @click="jshow_pop"></view>

      <view class="tc_fbox">
        <view class="tc_fbox_bt3" @click="btTC2">
          新增横道图内容
        </view>
        <view class="tc_fbox_bt2" @click="jshow_pop">
          横道图导出
        </view>
        <view class="tc_fbox_bt" @click="jshow_pop">
          取消
        </view>
      </view>
    </view>

    <!-- 弹出层 -->
    <view :class="[ashowpop2 ? 'tc' : 'tc hide']">
      <view class="jtop_bj" @click="btTCC"></view>

      <view class="tc_fbox">
        <view class="tc_fbox_bt3" @click="btTC_bj">
          编辑
        </view>
        <view class="tc_fbox_bt2" @click="btTC_jdel">
          删除
        </view>
        <view class="tc_fbox_bt" @click="btTCC">
          取消
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import request from '@/common/request.js';
import { mapState } from 'vuex';

export default {
  data() {
    return {
      repeat_click: true,
      ashowpop: false,
      ashowpop_jrename: false,
      ashowpop_jdel: false,
      ashowpopT: false,
      bj: false,
      yd: false,
      ashowpop2: false,
      projectId: '',
      nodata: false,
      items: [],
      jqeditid: '',
      aitems: [],
    };
  },

  methods: {
    lb() {
      this.projectId = uni.getStorageSync('dqfull_name').id;

      // 获取top信息
      request({
        url: `/biz/bar-chart/table-header`,
		method: 'GET',
        data: {
          page: 1,
          size: 10000,
        },
        success: res => {
          console.log('top信息', res);
          console.log(res.data.data.length);
          if (res.data.success == true) {
            console.log('1111:', res.data.data.length);
            if (res.data.data.length > 0) {
              this.aitems = res.data.data;
              console.log(this.aitems);
              this.nodata = false;
            } else {
              this.dqfull_name = '';
              this.nodata = true;
            }
          } else {
            this.repeat_click = true;
            uni.showToast({
              title: res.data.msg,
              icon: 'none',
            });
          }
        },
        fail: () => {
          this.repeat_click = true;
          uni.showToast({
            title: '服务器开小差，请稍后~',
            icon: 'none',
          });
          return false;
        },
      });

      // 获取列表信息
      request({
        url: `/biz/bar-chart/list`,
        method: 'GET',
        data: {
          page: 1,
          size: 10000,
        },

        success: res => {
          console.log('项目列表', res);
          console.log(res.data.data.length);
          if (res.data.success == true) {
            console.log('1111:', res.data.data.length);
            if (res.data.data.length > 0) {
              this.items = res.data.data;
              console.log(this.items);
              this.nodata = false;
            } else {
              this.dqfull_name = '';
              this.nodata = true;
            }
          } else {
            this.repeat_click = true;
            uni.showToast({
              title: res.data.msg,
              icon: 'none',
            });
          }
        },
        fail: () => {
          this.repeat_click = true;
          uni.showToast({
            title: '服务器开小差，请稍后~',
            icon: 'none',
          });
          return false;
        },
      });
    },

    btTC_bj() {
      var jc = this.items.filter(item => {
        return item.id == this.jqeditid;
      });
      console.log(jc);

      uni.setStorageSync('jc', jc[0]);

      uni.navigateTo({
        url: '../main/work_edit',
      });
    },
    logoTime(e) {
      console.log(e);
      this.jqeditid = e;
      this.ashowpop2 = true;
    },
    btTC_jdel() {
      var aa = this.jqeditid;
      request({
        url: `/biz/bar-chart-batch/${aa}`,
        method: 'DELETE',

        success: res => {
          if (res.data.success == true) {
            this.lb();
            this.ashowpop2 = false;
            wx.showToast({
              title: '删除成功',
              icon: 'none',
              duration: 1500,
              success: function() {
                setTimeout(function() {
                  this.lb();
                  //   uni.navigateTo({
                  // url: '../user/tream',
                  //   });
                }, 1500);
              },
            });
          } else {
            // 错误
            this.repeat_click = true;
            uni.showToast({
              title: res.data.msg,
              icon: 'none',
            });
          }
        },
        fail: () => {
          this.repeat_click = true;
          uni.showToast({
            title: '服务器开小差，请稍后~',
            icon: 'none',
          });
          return false;
        },
      });
    },
    btTCC(e) {
      this.ashowpop2 = !this.ashowpop2;
    },
    jf01() {
      uni.navigateTo({
        url: '../main/work',
      });
    },
    jf02() {
      uni.navigateTo({
        url: '../main/work_r',
      });
    },
    jf03() {
      uni.navigateTo({
        url: '../main/work_c',
      });
    },
    jf04() {
      uni.navigateTo({
        url: '../main/work_l',
      });
    },
    // 跳转
    jshow_pop() {
      this.ashowpop = !this.ashowpop;
    },
    btTC2() {
      uni.navigateTo({
        url: '../main/work_add',
      });
    },

    navigateBack() {
      uni.switchTab({
        url: 'main',
      });
    },
  },
  computed: mapState(['forcedLogin', 'hasLogin', 'userName']),

  onShow() {
    this.ashowpop2 = false;
    this.ashowpop = false;
    this.lb();
  },
};
</script>

<style>
.tophr {
  width: 100%;
  height: 88rpx;
}
.uni-searchbar {
  box-shadow: none;
}

.no {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  margin: 400rpx 0 0;
}
.no_t {
  width: 200rpx;
  height: 200rpx;
  display: block;
  float: left;
  margin: 0 275rpx;
  background: #ffffff;
  border-radius: 200rpx;
}
.no_t image {
  width: 140rpx;
  height: 140rpx;
  display: block;
  float: left;
  margin: 30rpx;
}
.no_c {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  margin: 30rpx 0 50rpx;
  color: #666666;
  font-size: 32rpx;
  line-height: 40rpx;
  text-align: center;
}
.no_f {
  width: 460rpx;
  height: 94rpx;
  line-height: 94rpx;
  background: #256aff;
  border-radius: 10rpx;
  display: block;
  float: left;
  margin: 0 145rpx;
  color: #ffffff;
  font-size: 36rpx;
  text-align: center;
}
.no_f:active {
  background: linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.199437),
      rgba(0, 0, 0, 0.199437)
    ),
    #256aff;
}

.wl_cbox {
  width: auto;
  height: auto;
  background: #ffffff;
  margin: 0 0 100rpx;
  white-space: nowrap;
}
.wl_c {
  width: auto;
  height: 80rpx;
  background: #ffffff;
  border-bottom: 1px solid #dddddd;
  white-space: nowrap;
  display: table-caption;
  overflow: hidden;
  text-align: center;
}
.wl_cb {
  height: 80rpx;
  padding: 0 0;
  display: block;
  text-align: center;
  font-size: 24rpx;
  line-height: 80rpx;
  color: #000000;
  border-right: 1px solid #dddddd;
  position: relative;
  display: inline-table;
}
.wl_c .wl_cb:last-child {
  border: 0px;
}
.wl_cb1 {
  width: 50rpx;
}
.wl_cb2 {
  width: 264rpx;
}
.wl_cb3 {
  width: 155rpx;
}
.wl_cb4 {
  width: 155rpx;
}
.wl_cb5 {
  width: 80rpx;
}
.wl_cb6 {
  width: 150rpx;
  position: relative;
}
.wl_cb6 em {
  height: 8rpx;
  background: #256aff;
  margin: 36rpx 0 0 0;
  display: block;
  float: left;
  position: relative;
  z-index: 2;
}
.wl_cb6 i {
  height: 80rpx;
  padding: 0 0;
  display: block;
  float: left;
  text-align: center;
  font-size: 24rpx;
  line-height: 80rpx;
  color: #000000;
  border-right: 1px solid #dddddd;
  position: absolute;
  top: 0;
  left: 0%;
  width: 33%;
  z-index: 1;
}
.wl_cb6 i.i2 {
  left: 33%;
}

.wl_top {
  width: auto;
  height: 90rpx;
  background: #f5f5f5;
  /* position: fixed; top: 88rpx; left: 0; z-index: 1000; */

  /* border-bottom: 1px solid #DDDDDD; */
  white-space: nowrap;
  /* display: table; overflow-y: hidden; */
}
.wl_t {
  height: 90rpx;
  padding: 0 0;
  display: block;
  text-align: center;
  font-size: 20rpx;
  line-height: 90rpx;
  color: #666666;
  border-right: 1px solid #dddddd; /*重点代码*/
  position: relative;
  display: inline-block;
  background: #f5f5f5;
  overflow: hidden;
  border-bottom: 1px solid #dddddd;
}
.wl_top .wl_t:last-child {
  border-right: 0px;
}
.wl_t1 {
  width: 50rpx;
}
.wl_t2 {
  width: 264rpx;
}
.wl_t3 {
  width: 156rpx;
  line-height: 30rpx;
  padding-top: 15rpx;
  box-sizing: border-box;
}
.wl_t4 {
  width: 156rpx;
  line-height: 30rpx;
  padding-top: 15rpx;
  box-sizing: border-box;
}
.wl_t5 {
  width: 82rpx;
  line-height: 30rpx;
  padding-top: 15rpx;
  box-sizing: border-box;
}
.wl_t6 {
  width: 150rpx;
}

.doc_bs {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
}
.doc_b {
  width: 720rpx;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
  border-bottom: 1px solid #dddddd;
  margin: 0 0 0 30rpx;
}
/* .doc_bs .doc_b:last-child{ border: 0;} */
.doc_bl {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
  margin: 36rpx 30rpx 36rpx 0;
}
.doc_bt {
  width: auto;
  height: 42rpx;
  line-height: 42rpx;
  font-size: 34rpx;
  display: block;
  float: left;
  color: #000000;
  margin: 37rpx 0 0 0;
}
.doc_br {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: right;
  margin: 32rpx 30rpx 32rpx 0;
}
.doc_b2 {
  width: 600rpx;
  height: auto;
  display: block;
  float: left;
}
.doc_b2t {
  width: 600rpx;
  height: auto;
  font-size: 34rpx;
  line-height: 42rpx;
  color: #000000;
  margin: 18rpx 0 10rpx;
  display: block;
  float: left;
}
.doc_b2f {
  width: 600rpx;
  height: auto;
  font-size: 24rpx;
  line-height: 32rpx;
  color: #fc9422;
  margin: 0rpx 0 rpx;
  display: block;
  float: left;
}

.index {
  background: #ffffff;
  width: 100%;
  height: auto;
}
.jtop {
  width: 100%;
  height: 88rpx;
  background: #ffffff;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  box-shadow: inset 0px -1px 0px #dddddd;
}
.jtop_l {
  width: auto;
  height: 88rpx;
  display: block;
  float: left;
  font-size: 32rpx;
  color: #000000;
  line-height: 88rpx;
  margin: 0 0 0 30rpx;
}
.jtop_l image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
  margin: 20rpx 0 20rpx 0;
}
.jtop_lt {
  margin: 0 0 0 10rpx;
}
.jtop_r {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: right;
  margin: 20rpx 20rpx 0 0;
}
.jtop_rl {
  margin: 20rpx 30rpx 0 0;
}
.jtop_r image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
}
.jtop_c {
  width: 70%;
  height: 48rpx;
  line-height: 48rpx;
  display: block;
  float: left;
  position: fixed;
  top: 20rpx;
  left: 15%;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
}
.jtop_c image {
  width: 36rpx;
  height: 36rpx;
  display: inline-block;
  float: none;
  margin-bottom: -5rpx;
  margin-left: 5rpx;
}
.jtop_b {
  width: 100%;
  height: auto;
  background: #ffffff;
  position: fixed;
  top: 88rpx;
  left: 0;
  z-index: 1001;
}

.doc_b22 {
  opacity: 0.5;
}

.nd {
  width: 735rpx;
  height: auto;
  display: block;
  float: left;
  margin: 0 0 0 0rpx;
}
.nd_bt {
  width: auto;
  height: 48rpx;
  display: block;
  float: right;
  border: 1px solid #dddddd;
  border-radius: 24rpx;
  margin: 40rpx 0 40rpx 30rpx;
}
.nd_bt text {
  width: auto;
  height: 48rpx;
  display: block;
  float: left;
  margin: 0 7rpx 0 18rpx;
  line-height: 48rpx;
  color: #666666;
  font-size: 24rpx;
}
.nd_bt image {
  width: 13rpx;
  height: 8rpx;
  display: block;
  float: left;
  margin: 21rpx 14rpx 0 0;
}

.tc {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  display: block;
}
.jtop_bj {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
}
.tc_fbox_bt {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-top: 20rpx solid #f2f2f2;
  background: #ffffff;
}
.tc_fbox {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #f2f2f2;
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 10001;
}
.tc_fbox_bt2 {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-top: 0rpx solid #f2f2f2;
  background: #ffffff;
}
.tc_fbox_bt3 {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-bottom: 1px solid #dddddd;
  background: #ffffff;
}

.wl_nr {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  overflow-x: auto;
}
.xx2 {
  width: 180rpx;
  height: 180rpx;
  display: block;
  float: left;
  position: fixed;
  right: 20rpx;
  bottom: 100rpx;
  z-index: 9999;
}
</style>
